import * as types from '../mutation-type'
const user = {
  state: {
    token: '',
    uid: '',
    loginEmail: ''
  },
  getters: {
    token: (state) => state.token,
    uid: (state) => state.uid,
    loginEmail: (state) => state.loginEmail
  },
  mutations: {
    [types.SET_TOKEN_UID] (state, data) {
      state.token = data.token
      state.uid = data.uid
      state.loginEmail = data.loginEmail
    },
    [types.DELETE_TOKEN_UID] (state) {
      state.token = ''
      state.uid = ''
      state.loginEmail = ''
    }
  },
  actions: {
    // loginByEmail ({commit}, userInfo) {
    //   return login(userInfo).then((res) => {
    //     if (res.status === 200) {
    //       commit('SET_TOKEN', res.token)
    //       commit('SET_UID', res.uid)
    //     } else if (res.status === 5555) {
    //     }
    //     return Promise.resolve(res.status)
    //   })
    // }
  }
}

export default user
